﻿Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Reflection
Imports System.Workflow.ComponentModel

Namespace System.Workflow.ComponentModel.Serialization
    Friend Class CompositeActivityTypeDescriptor
        Inherits CustomTypeDescriptor
        ' Methods
        Public Sub New(ByVal realTypeDescriptor As ICustomTypeDescriptor)
            MyBase.New(realTypeDescriptor)
            Me.realTypeDescriptor = realTypeDescriptor
        End Sub

        Public Overrides Function GetProperties(ByVal attributes As Attribute()) As PropertyDescriptorCollection
            Dim properties As PropertyDescriptorCollection = MyBase.GetProperties(attributes)
            If (((attributes Is Nothing) OrElse (attributes.Length <> 1)) OrElse (Not TypeOf attributes(0) Is DesignOnlyAttribute OrElse [TryCast](attributes(0),DesignOnlyAttribute).IsDesignOnly)) Then
                Return properties
            End If
            Dim list As New ArrayList
            Dim descriptor As PropertyDescriptor
            For Each descriptor In properties
                list.Add(descriptor)
            Next
            Dim property As PropertyInfo = GetType(CompositeActivity).GetProperty("CanModifyActivities", (BindingFlags.NonPublic Or BindingFlags.Instance))
            list.Add(New ModifyActivitiesPropertyDescriptor([property]))
            Return New PropertyDescriptorCollection(DirectCast(list.ToArray(GetType(PropertyDescriptor)), PropertyDescriptor()))
        End Function


        ' Fields
        Private realTypeDescriptor As ICustomTypeDescriptor
    End Class
End Namespace

